#include <regex>
#include <string>
#include <iostream>
using namespace std;

int main()
{
    std::smatch matchs;
    // 测试样例       "GET /lzz/login.html?user=lzz&pass=123456 HTTP/1.1\r\n";
    std::string str = "GET /hello HTTP/1.1\r\n";
    std::regex modle(R"((GET|HEAD|PUT|POST|DELETE|OPTIONS) ([^?]*)(?:\?(.*))? (HTTP/1.[10])(?:\r|\r\n))", std::regex::icase);
    if (std::regex_match(str, matchs, modle) == false)
        cout << "match error!" << endl;
    for (const auto& e : matchs)
        cout << e << endl;
    return 0;
}